

 class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }
public class demo1 {
    public boolean evaluateTree(TreeNode root) {
        if(root.left==null&&root.right==null)return root.val==0?false:true;
        boolean Lroot=evaluateTree(root.left);
        boolean Rroot=evaluateTree(root.right);
        if(root.val==2){
            return Lroot|Rroot;
        }else{
            return Lroot&Rroot;
        }
    }
}
